window.fbAsyncInit = function() {
	FB.init({
		appId : '162979493736782',
		status : true,
		cookie : true,
		xfbml : true
	});

	FB.Event.subscribe('auth.login', function(response) {
		// do something with response
		login();
		var uid = FB.getSession().uid;
		var access_token = FB.getSession().access_token;
		var param = "uid=" + encodeURIComponent(uid) + "&access_token="
				+ encodeURIComponent(access_token);
		location.href = "/LaSeC/Login?" + param;
	});

	FB.Event.subscribe('auth.logout', function(response) {
		// do something with response
		logout();
		location.href = "/LaSeC";
	});

	FB.getLoginStatus(function(response) {
		if (response.session) {
			login();
		}
	});
};

function userId() {
	FB.getLoginStatus(function(response) {
		if (response.session) {
			FB.api('/me', function(response) {
				var uid = response.id;
				return uid;
			});
		}
	});
}
